﻿using System;

namespace AbstractFactory
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // 示例1：使用Kmeans工厂（获取Kmeans算法+Kmeans参数）
                Console.WriteLine("=== Kmeans算法（带参数）执行结果 ===");
                IFactory kmeansFactory = new KmeansFactory();
                IClustering kmeans = kmeansFactory.CreateClustering();
                IParams kmeansParams = kmeansFactory.CreateParams();
                Console.WriteLine(kmeans.Calculate(kmeansParams));
                Console.WriteLine();

                // 示例2：使用Dbscan工厂（获取Dbscan算法+Dbscan参数）
                Console.WriteLine("=== Dbscan算法（带参数）执行结果 ===");
                IFactory dbscanFactory = new DbscanFactory();
                IClustering dbscan = dbscanFactory.CreateClustering();
                IParams dbscanParams = dbscanFactory.CreateParams();
                Console.WriteLine(dbscan.Calculate(dbscanParams));
                Console.WriteLine();

                // 示例3：使用层次聚类工厂（获取层次聚类算法+层次聚类参数）
                Console.WriteLine("=== 层次聚类算法（带参数）执行结果 ===");
                IFactory hierarchicalFactory = new HierarchicalFactory();
                IClustering hierarchical = hierarchicalFactory.CreateClustering();
                IParams hierarchicalParams = hierarchicalFactory.CreateParams();
                Console.WriteLine(hierarchical.Calculate(hierarchicalParams));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"程序出错：{ex.Message}");
            }

            Console.ReadLine();
        }
    }
}
